unit SaveFiles;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, FileCtrl;

type
  TFSaveDialog = class(TForm)
    DirectoryListBox1: TDirectoryListBox;
    Button1: TButton;
    Button2: TButton;
    DriveComboBox1: TDriveComboBox;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure Load(Index: Integer; Dir: string = '');
  end;

var
  FSaveDialog: TFSaveDialog;

implementation

uses main,GDocsCom;

{$R *.dfm}

procedure TFSaveDialog.Button1Click(Sender: TObject);
var i:integer;
begin
  with Form6.FolderTree1 do
  for i := 0 to SelectionCount - 1 do
    Load(Selections[i].AbsoluteIndex);
  ModalResult:=mrOk;
end;

procedure TFSaveDialog.Load(Index: Integer; Dir: string);
var i: Integer;
begin
  with Form6.FolderTree1 do
  begin
    if Items[Index].AbsoluteIndex = 0 then
      for i:=0 to Items[Index].Count-1 do
        Load(Items[Index].Item[i].AbsoluteIndex)
    else if TDocInfo(Items[Index].Data).DocumetnType = dtFolder then
      for i:=0 to Items[Index].Count-1 do
        Load(Items[Index].Item[i].AbsoluteIndex, Dir + TDocInfo(Items[Index].Data).FileName + '\')
    else
      Form6.GDocs1.LoadDocument(IncludeTrailingBackslash(DirectoryListBox1.Directory)+ Dir +TDocInfo(Items[Index].Data).FileName, TDocInfo(Items[Index].Data));
  end;
end;

procedure TFSaveDialog.Button2Click(Sender: TObject);
begin
  ModalResult:=mrCancel;
end;

end.
